print_title <- function(index, title_str) {
  print(paste0("", index, ", ", title_str, "------------"))
}


# 使用数据框
library(tidyverse)
print_title(1, "create tibble")
person=tibble(
Name=c("Ken", "Ashley", "Jennifer"),
Gender=c("Male", "Female", "Female"),
Age=c(24, 25, 23),
Major=c("Finance", "Statisctics", "Computer Science"))
print(person)



# summary
print_title(2, "summary")
tb_summary <- summary(person)
print(tb_summary)



# rbind
print_title(3, "after rbind")
rbind_table <- rbind(person,
      tibble(Name="John", Gender="Male", Age=25, Major="Statistics"))
print(rbind_table)


# cbind
print_title(4, "after cbind")
cbind_table <- cbind(person, Registered=c(TRUE, TRUE, FALSE), Projects=c(3, 2, 3))
print(cbind_table)



# expand.grid()
print_title(5, "expand.grid()")
tb_grid = expand.grid(type=c("A", "B"), class=c("M", "L", "XL"))
print(tb_grid)